(ns clj.ex1)
(import '(com.aligotec Address User))
(import '(org.jsoup Jsoup))
(import '(org.jsoup.nodes Document))

(defn test1 [& args]
  (println "Playing in first test1 " args)
  (let [user (doto (User.) (.setName "Bill") (.setBirth "2000-01-01") (.setAddress (doto (Address.)  (.setNumber 104) (.setStreet "street-1") (.setTown "Bucharest") )) )]
    (.. user (getAddress) (setCountry "Romania"))
    (println "Created user " user)
    
    (def user-bean (bean user))
    (println "Created bean " user-bean)
    
;    (defn rec-bean [j-obj]
;      ;will recursivly bean the j-obj java object
;      (let [b (bean j-obj)]
;        (println "rec-bean on user ")
;        (filter )
;      b )
;    )
    
    ;(rec-bean user)

    (def user-bean (assoc user-bean :address (bean (.getAddress user)) ) )
    (println "Modified bean " user-bean)
    
    
    ((fn [{name :name, birth :birth, department :department, email :email, {number :number} :address ;, number (:number addr)
           :or {department 101, email "default@comany.com"}}]
       
       (println "User destructured as " name " b:" birth " d:" department " e:" email " num: " number)) 
           user-bean )
    
    )
  
  "test1 finished")